#ifndef SIMPLEVEC_H
#define SIMPLEVEC_H

#include <cmath> // for sqrt

typedef float vec_float;

class svec // simple 3D vector class
{
  public:
    vec_float x,y,z;

    svec() {}
    svec( vec_float xx, vec_float yy, vec_float zz )
    { x=xx; y=yy; z=zz; }

    inline svec operator + (svec t) // addition
    { return svec(x+t.x,y+t.y,z+t.z); }
    inline svec operator - (svec t) // subtraction
    { return svec(x-t.x,y-t.y,z-t.z); }
    inline svec operator * (vec_float t) // dot product
    { return svec(x*t,y*t,z*t); }
    inline vec_float operator * (svec t) // scalar product
    { return x*t.x + y*t.y + z*t.z; }
    inline svec operator ^ (svec t) // cross product
    { return svec( y*t.z-z*t.y, t.x*z-x*t.z, x*t.y-y*t.x ); }

    inline vec_float length() // pythagorean length
    { return sqrt(x*x + y*y + z*z); }
    inline svec unit() // normalized to a length of 1
    { vec_float l = length();
      if (l == 0.0) return svec(0.0,0.0,0.0);
      return svec(x/l,y/l,z/l); }
    inline bool zero() // returns true if a zero vector
    { return x==0 && y==0 && z==0; }
    inline bool equals(svec t) // returns true if exactly equal
    { return x==t.x && y==t.y && z==t.z; }
};

//extern void arcball_setzoom(float radius, vec eye, vec up);
//extern void arcball_rotate();
//extern void arcball_reset();
//extern void arcball_start(int mx, int my);
//extern void arcball_move(int mx, int my);

#endif
